AttributeError: module ‘cv2‘ has no attribute ‘face‘的解决

您所在的位置:网站首页 face是什么意思 翻译 AttributeError: module ‘cv2‘ has no attribute ‘face‘的解决

AttributeError: module ‘cv2‘ has no attribute ‘face‘的解决

2023-07-17 07:57| 来源: 网络整理| 查看: 265

问题描述

在使用cv2.face.LBPHFaceRecognizer_create()进行人脸识别的操作时,会出现这样的提示:

 

从官网上我们看到,face模块实际上并不是opencv图书馆的一部分。更确切地说,face是部分的的opencv-contrib库。从自述文件:此存储库[ opencv-contrib]用于开发所谓的“额外”模块,提供功能。新模块通常没有稳定的API,并且它们没有经过良好测试。因此,它们不应作为官方OpenCV发行版的一部分发布,因为该库保持二进制兼容性,并试图提供良好的性能和稳定性。 之所以出现这种情况,是因为缺少了相关的包。

首先切换到你所在的环境(不建议在base环境中直接下载):

conda activate tf 问题解决

接着就是下载我们需要的相关的包,两种方法:

官方方法:

pip install opencv-contrib-python

更快的方法,利用豆瓣下载:

pip install Pyinstaller -i http://pypi.douban.com/simple --trusted-host pypi.douban.com

 结果展示:

如果直接安装不行,就要全部卸载一遍,然后重新安装。

pip uninstall opencv-contrib-python pip uninstall opencv-python pip install opencv-python pip install opencv-contrib-python

 

 看到successfully之后就可以运行代码啦!



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3